(function() {
	Path.on("/user/__basename__.html",function (_current_location) {
		var queryString = _current_location.query;
		var _type = queryString.get("type");
		if (_type == 2) {
			App.set('title', '导购链接');
			App.set('$Cache.user.buff.infotype', 'shoppinguide');
			coAjax.get(appConfig.user.guide_list, function(result) {
				console.log(result.result);
				App.set("$Cache.user.buff.guide_list", result.result);
			});
			// 导购

			App.set("$Event.user.buff.guide.weishenqingduihuan_to_shenqingduihuanzhong", function(e, vm) {
				coAjax.put(appConfig.user.guide_weishenqingduihuan_to_shenqingduihuanzhong, {
					bus_id: vm.get("bus_id")
				}, function(result) {
					console.log(result.result);
					vm.set(result.result);
				})
			});
			App.set("$Event.user.buff.guide.shangjiayijingfukuan_to_yonghuquerenfukuan", function(e, vm) {
				coAjax.put(appConfig.user.guide_shangjiayijingfukuan_to_yonghuquerenfukuan, {
					bus_id: vm.get("bus_id")
				}, function(result) {
					console.log(result.result);
					vm.set(result.result);
				})
			});
		} else if (_type == 3) {
			App.set('title', '分销管理');
			App.set('$Cache.user.buff.infotype', 'distribution');
			coAjax.get(appConfig.user.bina.all, function(result) {
				App.set("$Cache.user.buff.user_bina.all", result.result);
			});

			App.set("$Event.user.buff.user_bina.未申请兑换_to_申请兑换中", function(e, vm) {
				if (!App.get("loginer.info.alipay")) {
					alert("warn", "您还未绑定支付宝账号，请到“个人信息”页进行设置，确保兑现顺利进行", 5000)
				}
				coAjax.put(appConfig.user.bina.未申请兑换_to_申请兑换中, {
					bus_id: vm.get("bus_id")
				}, function(result) {
					vm.set(result.result);
				});
			});
			App.set("$Event.user.buff.user_bina.商家已付款_to_用户确认付款", function(e, vm) {
				coAjax.put(appConfig.user.bina.商家已付款_to_用户确认付款, {
					bus_id: vm.get("bus_id")
				}, function(result) {
					vm.set(result.result);
				});
			});
			App.set("$Event.user_bina.open_first_acc_users", function(e, vm) {
				vm.set("_show_first_acc_users", true);
				// if (!vm.get("first_acc_users")) {
				coAjax.get(appConfig.user.bina.first_acc_users + vm.get("bus_id"), function(result) {
					vm.set("first_acc_users", result.result);
				});
				// }
			});
			App.set("$Event.user_bina.close_first_acc_users", function(e, vm) {
				vm.set("_show_first_acc_users", false);
			});
		} else {
			App.set('$Cache.user.buff.infotype', '');
			coAjax.get(appConfig.user.bus_bind, function(result) {
				console.log(result.result);
				App.set("$Cache.user.buff.bus_user_bind", result.result);
			});
			App.set('title', '推荐返利');
			App.set("$Event.user.buff.weishenqingduihuan_to_shenqingduihuanzhong", function(e, vm) {
				coAjax.put(appConfig.user.res_weishenqingduihuan_to_shenqingduihuanzhong, {
					bus_id: vm.get("bus_id")
				}, function(result) {
					console.log(result.result);
					vm.set(result.result);
				})
			})

			App.set("$Event.user.buff.shangjiayijingfukuan_to_yonghuquerenfukuan", function(e, vm) {
				coAjax.put(appConfig.user.res_shangjiayijingfukuan_to_yonghuquerenfukuan, {
					bus_id: vm.get("bus_id")
				}, function(result) {
					console.log(result.result);
					vm.set(result.result);
				})
			});

		}
	});
}());